<?php
// 查询users表结构的脚本
header('Content-Type: text/html; charset=utf-8');

try {
    // 连接数据库
    $pdo = new PDO('mysql:host=localhost;dbname=blog;charset=utf8', 'root', 'root');
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    
    // 查询users表的结构
    $stmt = $pdo->query('DESCRIBE users');
    $columns = $stmt->fetchAll(PDO::FETCH_ASSOC);
    
    echo '<h2>users表结构</h2>';
    echo '<table border="1" cellspacing="0" cellpadding="5">';
    echo '<tr><th>字段名</th><th>类型</th><th>是否为空</th><th>键</th><th>默认值</th><th>额外信息</th></tr>';
    
    foreach ($columns as $column) {
        echo '<tr>';
        echo '<td>'.htmlspecialchars($column['Field']).'</td>';
        echo '<td>'.htmlspecialchars($column['Type']).'</td>';
        echo '<td>'.htmlspecialchars($column['Null']).'</td>';
        echo '<td>'.htmlspecialchars($column['Key']).'</td>';
        echo '<td>'.htmlspecialchars($column['Default'] ?? 'NULL').'</td>';
        echo '<td>'.htmlspecialchars($column['Extra']).'</td>';
        echo '</tr>';
    }
    
    echo '</table>';
    
} catch (PDOException $e) {
    echo '数据库连接失败: ' . $e->getMessage();
}